/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Guis.Tarea;

import Clases.Responsable;
import Clases.Tarea;
import Controlador.ControladorCategoria;
import Controlador.ControladorResponsable;
import Controlador.ControladorTarea;
import static Guis.Principal.Principal.jDesktopPane1;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.Calendar;
import javax.swing.InputMap;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.KeyStroke;

/**
 *
 * @author Angelo
 */
public class ModificarTarea extends javax.swing.JDialog {

    private Tarea tarea;
    private ControladorTarea ct;

    public ModificarTarea(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setResizable(false);
        this.setTitle("Modificar Tarea");
        Dimension desktopSize = jDesktopPane1.getSize();
        Dimension jInternalFrameSize = this.getSize();
        this.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
                (desktopSize.height - jInternalFrameSize.height) / 2);
        //********************************************************************//
        this.BloquearCopiar(jTextField1);
        this.MaximoCaracteres256(jTextField1);
        this.MaximoCaracteres4000(txt_Descripcion);
        //****************      **************************       *************//      
        txt_Vencimiento.setEnabled(false);
        txt_Vencimiento.getCalendarButton().setEnabled(true);
        txt_Descripcion.setLineWrap(true);
        //****************      **************************       *************//
        ct = new ControladorTarea();
        cargarCombos();
        this.jTextField1.setEnabled(false);
        this.txt_Responsable.setEnabled(false);

        this.jButton1.addKeyListener(new java.awt.event.KeyAdapter() {
            @Override
            public void keyPressed(java.awt.event.KeyEvent e) {
                if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                    cambiarEstado();
                }
            }
        });
        this.btn_CambiarResponsable.addKeyListener(new java.awt.event.KeyAdapter() {
            @Override
            public void keyPressed(java.awt.event.KeyEvent e) {
                if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                    cambiarResponsable();
                }
            }
        });
        this.btn_Guardar.addKeyListener(new java.awt.event.KeyAdapter() {
            @Override
            public void keyPressed(java.awt.event.KeyEvent e) {
                if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                    guardarCambios();
                }
            }
        });
        this.btn_Limpiar.addKeyListener(new java.awt.event.KeyAdapter() {
            @Override
            public void keyPressed(java.awt.event.KeyEvent e) {
                if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                    limpiarCampos();
                }
            }
        });
        this.btn_Salir.addKeyListener(new java.awt.event.KeyAdapter() {
            @Override
            public void keyPressed(java.awt.event.KeyEvent e) {
                if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                    dispose();
                }
            }
        });

    }

    private void BloquearCopiar(JTextField a) {
        // BLOQUEA LA ACCION COPIAR 
        InputMap map2 = a.getInputMap(JTextField.WHEN_FOCUSED);
        map2.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK), "null");
    }

    private void MaximoCaracteres256(JTextField a) {
        a.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {
                JTextField a = (JTextField) e.getSource();
                if (a.getText().length() == 256) {
                    getToolkit().beep();
                    e.consume();
                }
            }
        });
    }

    private void MaximoCaracteres4000(JTextArea a) {
        a.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {
                JTextArea a = (JTextArea) e.getSource();
                if (a.getText().length() == 4000) {
                    getToolkit().beep();
                    e.consume();
                }
            }
        });
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txt_Descripcion = new javax.swing.JTextArea();
        jLabel4 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        cmb_Prioridad = new javax.swing.JComboBox();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        txt_Vencimiento = new com.toedter.calendar.JDateChooser();
        jLabel5 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        txt_Responsable = new javax.swing.JTextField();
        btn_CambiarResponsable = new javax.swing.JButton();
        txt_Titulo = new javax.swing.JTextField();
        jComboBox1 = new javax.swing.JComboBox();
        jTextField1 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        btn_Guardar = new javax.swing.JButton();
        btn_Limpiar = new javax.swing.JButton();
        btn_Salir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setToolTipText("Tarea Seleccionada");

        jLabel1.setText("Titulo:");

        jLabel2.setText("Responsable:");

        jLabel3.setText("Descripción:");

        txt_Descripcion.setColumns(20);
        txt_Descripcion.setRows(5);
        jScrollPane2.setViewportView(txt_Descripcion);

        jLabel4.setText("Prioridad");

        jLabel7.setText("Categoría");

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel6.setText("Estado:");

        jLabel5.setText("Vencimiento:");

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox4ActionPerformed(evt);
            }
        });

        txt_Responsable.setEditable(false);

        btn_CambiarResponsable.setText("Cambiar");
        btn_CambiarResponsable.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_CambiarResponsableActionPerformed(evt);
            }
        });

        jButton1.setText("Cambar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txt_Titulo, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txt_Responsable, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btn_CambiarResponsable)))
                        .addGap(30, 30, 30))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txt_Vencimiento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addGap(18, 18, 18)
                                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel4))
                                .addGap(27, 27, 27)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmb_Prioridad, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(27, 27, 27)
                                        .addComponent(jButton1)))))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(txt_Titulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txt_Responsable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btn_CambiarResponsable)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(cmb_Prioridad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(17, 17, 17)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(txt_Vencimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23))
        );

        btn_Guardar.setText("Guardar");
        btn_Guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_GuardarActionPerformed(evt);
            }
        });

        btn_Limpiar.setText("Limpiar");
        btn_Limpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_LimpiarActionPerformed(evt);
            }
        });

        btn_Salir.setText("Salir");
        btn_Salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_SalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addComponent(btn_Guardar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_Limpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(81, 81, 81)
                        .addComponent(btn_Salir, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(62, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_Guardar)
                    .addComponent(btn_Limpiar)
                    .addComponent(btn_Salir))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox4ActionPerformed

    private void btn_SalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_SalirActionPerformed
        Salir();
    }//GEN-LAST:event_btn_SalirActionPerformed

    private void btn_LimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_LimpiarActionPerformed
        limpiarCampos();
    }//GEN-LAST:event_btn_LimpiarActionPerformed

    private void btn_GuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_GuardarActionPerformed
        guardarCambios();
    }//GEN-LAST:event_btn_GuardarActionPerformed

    private void btn_CambiarResponsableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CambiarResponsableActionPerformed
        cambiarResponsable();
    }//GEN-LAST:event_btn_CambiarResponsableActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        cambiarEstado();
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_CambiarResponsable;
    private javax.swing.JButton btn_Guardar;
    private javax.swing.JButton btn_Limpiar;
    private javax.swing.JButton btn_Salir;
    private javax.swing.JComboBox cmb_Prioridad;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextArea txt_Descripcion;
    private javax.swing.JTextField txt_Responsable;
    private javax.swing.JTextField txt_Titulo;
    private com.toedter.calendar.JDateChooser txt_Vencimiento;
    // End of variables declaration//GEN-END:variables

    private void guardarCambios() {
        if (validar()) {
            tarea.setPrioridad(cmb_Prioridad.getSelectedIndex());
            tarea.setTexto(txt_Descripcion.getText());
            tarea.setTitulo(txt_Titulo.getText());
            Calendar c = txt_Vencimiento.getCalendar();
            c.set(Calendar.HOUR_OF_DAY, jComboBox3.getSelectedIndex());
            c.set(Calendar.MINUTE, jComboBox4.getSelectedIndex());
            tarea.setVencimiento(c.getTime());
            tarea.setId_Categoria(ct.getId_CategoriaIndex(jComboBox1.getSelectedIndex()));
            if (ct.modificarTarea(tarea)) {
                JOptionPane.showMessageDialog(rootPane, "Tarea modificada");
                dispose();
            } else {
                JOptionPane.showMessageDialog(rootPane, "No se pudo modificar la tarea");
            }
        }
    }

    private boolean validar() {
        boolean flag = true;
        if (txt_Vencimiento.getCalendar() == null || jComboBox3.getSelectedIndex() == -1 || jComboBox4.getSelectedIndex() == -1) {
            flag = false;
            jLabel5.setForeground(Color.red);
        } else {
            jLabel5.setForeground(Color.black);
        }
        if (txt_Titulo.getText().isEmpty()) {
            jLabel1.setForeground(Color.red);
            flag = false;
        } else {
            jLabel1.setForeground(Color.black);
        }

        if (txt_Descripcion.getText().isEmpty()) {
            jLabel3.setForeground(Color.red);
            flag = false;
        } else {
            if (txt_Descripcion.getText().length() > 4000) {
                jLabel3.setForeground(Color.red);
                flag = false;
                JOptionPane.showMessageDialog(rootPane, "La descripcion no deve superar los 4000 caracteres.");
            } else {
                jLabel3.setForeground(Color.black);
            }
        }
        if (jComboBox1.getSelectedIndex() == -1) {
            jLabel7.setForeground(Color.red);
            flag = false;
        } else {
            jLabel7.setForeground(Color.black);
        }
        if (cmb_Prioridad.getSelectedIndex() == -1) {
            jLabel4.setForeground(Color.red);
            flag = false;
        } else {
            jLabel4.setForeground(Color.black);
        }
        return flag;
    }

    private void Salir() {
        this.dispose();
    }

    private void limpiarCampos() {

        jComboBox1.setSelectedIndex(-1);
        cmb_Prioridad.setSelectedIndex(-1);
        jComboBox3.setSelectedIndex(-1);
        jComboBox4.setSelectedIndex(-1);

        txt_Vencimiento.setDate(null);
        txt_Descripcion.setText("");
        txt_Titulo.setText("");

    }

    private void cargarCombos() {
        jComboBox3.removeAllItems();
        jComboBox4.removeAllItems();

        for (int i = 0; i <= 23; i++) {
            jComboBox3.addItem(i);
        }
        for (int i = 0; i <= 59; i++) {
            jComboBox4.addItem(i);
        }

        jComboBox1.setModel(ct.getComboCategorias().getModel());
        cmb_Prioridad.removeAllItems();
        cmb_Prioridad.addItem("Alta");
        cmb_Prioridad.addItem("Media");
        cmb_Prioridad.addItem("Baja");
    }

    private void cargarTarea() {
        ControladorResponsable cr = new ControladorResponsable();
        ControladorCategoria cc = new ControladorCategoria();

        txt_Titulo.setText(tarea.getTitulo());
        txt_Responsable.setText(cr.getResponsable(tarea.getId_Responsable()).getNombre());
        txt_Vencimiento.setDate(tarea.getVencimiento());
        txt_Descripcion.setText(tarea.getTexto());
        jTextField1.setText("" + tarea.getCompletado());

        cmb_Prioridad.setSelectedItem(tarea.getPrioridadString());
        jComboBox1.setSelectedItem(cc.getCategoria(tarea.getId_Categoria()).getNombre());
        jComboBox3.setSelectedIndex(tarea.getVencimiento().getHours());
        jComboBox4.setSelectedIndex(tarea.getVencimiento().getMinutes());
    }

    private void cambiarResponsable() {
        CambiarResponsable.getResponsable(new java.awt.Frame(), true, ct, tarea);
        Responsable respSelec = CambiarResponsable.getResponsableSeleccionado();
        txt_Responsable.setText(respSelec.getNombre());
        tarea.setId_Responsable(respSelec.getId_Responsable());
    }

    void setTarea(Tarea tarea) {
        this.tarea = tarea;
        this.cargarTarea();
    }

    private void cambiarEstado() {
        CambiarEstado.setTarea(tarea);
        CambiarEstado ce = new CambiarEstado(null, true);
        ce.setVisible(true);
        tarea = CambiarEstado.getTarea();
        jTextField1.setText("" + tarea.getCompletado());
    }
}
